package com.yanqu.road.server.cmd.player;

import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_SEARCH_PLAYER, desc = "跨服查找玩家信息")
public class CrossSearchPlayerCmd extends CrossCommand {
    private long userId;
    private long searchServerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PlayerProto.SearchPlayerReqMsg reqMsg = PlayerProto.SearchPlayerReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        searchServerId = reqMsg.getServerId();
        PlayerProto.CrossSearchPlayerReqMsg.Builder msg = PlayerProto.CrossSearchPlayerReqMsg.newBuilder();
        msg.setUserId(userId);
        msg.setServerId(serverId);
        msg.setSearchUserAliasId(reqMsg.getUserAliasId());
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_TO_SEARCH_PLAYER, msg);
        MessageHelper.sendPacket(searchServerId, 0, pbMsg);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
